package luz.javaproxy.proxy;

import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpException;
import org.apache.http.nio.NHttpConnection;
import org.apache.http.nio.protocol.EventListener;

class HttpProxyEventLogger implements EventListener {
	private static final Log log = LogFactory.getLog(HttpProxyEventLogger.class);
	String info="Server";

	
	HttpProxyEventLogger(){
		super();
	}

    public void connectionOpen(final NHttpConnection conn) {
        log.info(info+" Connection opened: " + conn);
    }

    public void connectionClosed(final NHttpConnection conn) {
        log.info(info+" Connection closed: " + conn);
    }
    
    public void connectionTimeout(final NHttpConnection conn) {
    	log.warn(info+" Connection timed out: " + conn);
    }

    public void fatalIOException(final IOException ex, final NHttpConnection conn) {
    	log.error(info+" I/O error: " + ex.getMessage());
    }

    public void fatalProtocolException(final HttpException ex, final NHttpConnection conn) {
    	log.error(info+" HTTP error: " + ex.getMessage());
    }
}